package com.yunzheng.studyLeaveSystem.modules.user.user_info.servlet; /**
 * Created with IntelliJ IDEA.
 *
 * @Author: YunZheng
 * @Date: 2023/01/31/15:55
 * @Description:
 */

import com.alibaba.fastjson.JSON;
import com.yunzheng.studyLeaveSystem.modules.user.user_info.entity.User_info;
import com.yunzheng.studyLeaveSystem.modules.user.user_info.service.User_infoService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "User_infoServlet", value = "/User_infoServlet")
public class User_infoServlet extends HttpServlet {
    private User_infoService user_infoService = new User_infoService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        String phone_num = (String) session.getAttribute("phone_num");
        User_info user_info = null;
        try {
            user_info = user_infoService.getUser_info(phone_num);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        String s = JSON.toJSONString(user_info);
        request.setAttribute("user_info", s);
        //返回记录页面(暂时未知)
        request.getRequestDispatcher("/").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
